package com.tencreat.service.pt.impl;

import java.time.LocalDateTime;
import java.util.List;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tencreat.common.core.domain.model.ReqIdParam;
import com.tencreat.common.core.domain.model.ReqIdsParam;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tencreat.domain.pt.MallPtSignCouponRecord;
import com.tencreat.domain.pt.vo.ResMallPtSignCouponRecordVo;
import com.tencreat.mapper.pt.MallPtSignCouponRecordMapper;
import com.tencreat.service.pt.IMallPtSignCouponRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 【拼团券签到记录】Service业务层处理
 *
 * @author tencreat
 * @date 2021-11-24
 */
@Service
public class MallPtSignCouponRecordServiceImpl extends ServiceImpl<MallPtSignCouponRecordMapper, MallPtSignCouponRecord> implements IMallPtSignCouponRecordService {

    @Autowired
    MallPtSignCouponRecordMapper mallPtSignCouponRecordMapper;

    /**
     * 查询【请填写功能名称】
     *
     * @param id 【请填写功能名称】ID
     * @return 【请填写功能名称】
     */
    @Override
    public MallPtSignCouponRecord selectMallPtSignCouponRecordById(ReqIdParam id) {
        return baseMapper.selectById(id.getId());
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param mallPtSignCouponRecord 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<MallPtSignCouponRecord> selectMallPtSignCouponRecordList(MallPtSignCouponRecord mallPtSignCouponRecord) {
        return baseMapper.selectList(Wrappers.query(mallPtSignCouponRecord));
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param mallPtSignCouponRecord 【请填写功能名称】
     * @return 结果
     */
            @Override
    public int insertMallPtSignCouponRecord(MallPtSignCouponRecord mallPtSignCouponRecord) {
    mallPtSignCouponRecord.setCreateTime(LocalDateTime.now());
        return baseMapper.insert(mallPtSignCouponRecord);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param mallPtSignCouponRecord 【请填写功能名称】
     * @return 结果
     */
            @Override
    public int updateMallPtSignCouponRecord(MallPtSignCouponRecord mallPtSignCouponRecord) {
        return baseMapper.updateById(mallPtSignCouponRecord);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param ids 需要删除的【请填写功能名称】ID
     * @return 结果
     */
            @Override
    public int deleteMallPtSignCouponRecordByIds(ReqIdsParam ids) {
        return baseMapper.deleteBatchIds(ids.getId());
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param id 【请填写功能名称】ID
     * @return 结果
     */
    @Override
    public int deleteMallPtSignCouponRecordById(ReqIdParam id) {
        return baseMapper.deleteById(id.getId());
    }

    @Override
    public Page<ResMallPtSignCouponRecordVo> signList(Page<ResMallPtSignCouponRecordVo> page, ResMallPtSignCouponRecordVo mallPtSignCouponRecordVo) {
        Page<ResMallPtSignCouponRecordVo> recordVoPage = mallPtSignCouponRecordMapper.signList(page, mallPtSignCouponRecordVo);
        for(ResMallPtSignCouponRecordVo mallPtSignCouponRecord : recordVoPage.getRecords()){
            String uuid = mallPtSignCouponRecord.getUuid();
            String count = mallPtSignCouponRecordMapper.signListCount(uuid);
            mallPtSignCouponRecord.setUserRoll(count);
        }
        return recordVoPage;

    }
}
